package com.example.recyclerviewlearn;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class MainActivity extends Activity {
    private static final String TAG = "MainActivity";

    RecyclerCoverFlowView mRecyclerView;


    CustomLayoutManagerTwo animationLinearLayoutManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        MyAdapter myAdapter = new MyAdapter(MainActivity.this, initData());
        mRecyclerView = findViewById(R.id.recyclerView);
//        final myLinearLayoutManager myLinearLayoutManager = new myLinearLayoutManager();
//        mmyLinearLayoutManager = myLinearLayoutManager;
//        mmyLinearLayoutManager.setStackFromEnd();

        animationLinearLayoutManager = new CustomLayoutManagerTwo();
        mRecyclerView.setLayoutManager(animationLinearLayoutManager);
        mRecyclerView.setAdapter(myAdapter);
        mRecyclerView.scrollToPosition(10);

    }

    //初始化数据
    private List<String> initData() {
        int size = 60;
        List<String> myData = new ArrayList<>(size);
        for (int i = 0; i < size; i++) {
            myData.add("str: " + i);
        }
        return myData;
    }

    @Override
    protected void onResume() {
        super.onResume();
        animationLinearLayoutManager.scrollToPosition(50);
//        Animation animation = AnimationUtils.loadAnimation(this, R.anim.scaleanim_scale_1);
//        int posision = animationLinearLayoutManager.findFirstCompletelyVisibleItemPosition();
//        View view = animationLinearLayoutManager.findViewByPosition(posision);
//        view.startAnimation(animation);
    }

    @Override
    protected void onPause() {
        super.onPause();
    }
}
